home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / distress-selection.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  3.8 KB  |  116 lines

  1. ;
  2. ; distress selection
  3. ;
  4. ;
  5. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  6. ; At ECS Dept, University of Southampton, England.
  7.  
  8. ; This program is free software: you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  
  21. ; Define the function:
  22.  
  23. (define (script-fu-distress-selection inImage
  24.                                       inDrawable
  25.                                       inThreshold
  26.                                       inSpread
  27.                                       inGranu
  28.                                       inSmooth
  29.                                       inSmoothH
  30.                                       inSmoothV)
  31.  
  32.   (let (
  33.        (theImage inImage)
  34.        (theWidth (car (gimp-image-width inImage)))
  35.        (theHeight (car (gimp-image-height inImage)))
  36.        (theLayer 0)
  37.        (theMode (car (gimp-image-base-type inImage)))
  38.        )
  39.  
  40.   (gimp-image-undo-group-start theImage)
  41.   (if (= theMode GRAY)
  42.     (set! theMode GRAYA-IMAGE)
  43.     (set! theMode RGBA-IMAGE)
  44.     )
  45.   (set! theLayer (car (gimp-layer-new theImage
  46.                                       theWidth
  47.                                       theHeight
  48.                                       theMode
  49.                                       "Distress Scratch Layer"
  50.                                       100
  51.                                       NORMAL-MODE)))
  52.  
  53.   (gimp-image-add-layer theImage theLayer 0)
  54.  
  55.   (if (= FALSE (car (gimp-selection-is-empty theImage)))
  56.       (gimp-edit-fill theLayer BACKGROUND-FILL)
  57.   )
  58.  
  59.   (gimp-selection-invert theImage)
  60.  
  61.   (if (= FALSE (car (gimp-selection-is-empty theImage)))
  62.       (gimp-edit-clear theLayer)
  63.   )
  64.  
  65.   (gimp-selection-invert theImage)
  66.   (gimp-selection-none inImage)
  67.  
  68.   (gimp-layer-scale theLayer
  69.                     (/ theWidth inGranu)
  70.                     (/ theHeight inGranu)
  71.                     TRUE)
  72.  
  73.   (plug-in-spread RUN-NONINTERACTIVE
  74.                   theImage
  75.                   theLayer
  76.                   inSpread
  77.                   inSpread)
  78.  
  79.   (plug-in-gauss-iir RUN-NONINTERACTIVE
  80.              theImage theLayer inSmooth inSmoothH inSmoothV)
  81.   (gimp-layer-scale theLayer theWidth theHeight TRUE)
  82.   (plug-in-threshold-alpha RUN-NONINTERACTIVE theImage theLayer inThreshold)
  83.   (plug-in-gauss-iir RUN-NONINTERACTIVE theImage theLayer 1 TRUE TRUE)
  84.   (gimp-selection-layer-alpha theLayer)
  85.   (gimp-image-remove-layer theImage theLayer)
  86.   (if (and (= (car (gimp-drawable-is-channel inDrawable)) TRUE)
  87.            (= (car (gimp-drawable-is-layer-mask inDrawable)) FALSE))
  88.     (gimp-image-set-active-channel theImage inDrawable)
  89.     )
  90.   (gimp-image-undo-group-end theImage)
  91.  
  92.   (gimp-displays-flush)
  93.   )
  94. )
  95.  
  96.  
  97. (script-fu-register "script-fu-distress-selection"
  98.   _"_Distort..."
  99.   _"Distress the selection"
  100.   "Chris Gutteridge"
  101.   "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  102.   "23rd April 1998"
  103.   "RGB*,GRAY*"
  104.   SF-IMAGE       "The image"              0
  105.   SF-DRAWABLE    "The layer"              0
  106.   SF-ADJUSTMENT _"Threshold (bigger 1<-->255 smaller)" '(127 1 255 1 10 0 0)
  107.   SF-ADJUSTMENT _"Spread"                 '(8 0 1000 1 10 0 1)
  108.   SF-ADJUSTMENT _"Granularity (1 is low)" '(4 1 25 1 10 0 1)
  109.   SF-ADJUSTMENT _"Smooth"                 '(2 1 150 1 10 0 1)
  110.   SF-TOGGLE     _"Smooth horizontally"    TRUE
  111.   SF-TOGGLE     _"Smooth vertically"      TRUE
  112. )
  113.  
  114. (script-fu-menu-register "script-fu-distress-selection"
  115.                          "<Image>/Select/Modify")
  116.